package SQL.query;

import SQL.abysnSQL.ColName;

/*
 * createindex ::= CREATE uniq:uni INDEX ID:in ON ID:tn LBRACE colname : cn RBRACE
		{:RESULT = new CreateIndex(uni,in,tn,cn);:}|
 */
public class CreateIndex extends SQL {
	public boolean unique;
	public String indexname;
	public String tblname;
	public ColName colname;
	
	public CreateIndex(boolean uni, String id, String tn, ColName cn){
		unique = uni;
		indexname = id;
		tblname = tn;
		colname = cn;
	}
	
	public boolean isUnique(){
		return unique;
	}
	
	public String getIndexName(){
		return indexname;
	}
	
	public String getTblName(){
		return tblname;
	}
	
	public String getColName(){
		return colname.toString();
	}
	
	public String toString(){
		if(unique){
			return "CREATE UNIQUE INDEX "+ indexname +" ON "+tblname +"("+colname+")";
		}
		else
			return "CREATE INDEX "+ indexname +" ON "+tblname +"("+colname+")";
	}
	
}
	
